package com.ia.aistream.controller.operating;//package com.ia.aistream.controller.operating;

import java.util.List;


import com.ia.aistream.common.annotation.Log;
import com.ia.aistream.model.operating.entity.DocTitle;
import com.ia.aistream.service.operating.IDocTitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ia.aistream.common.enums.BusinessType;

import com.ia.aistream.common.core.controller.BaseController;
import com.ia.aistream.common.core.domain.AjaxResult;
import com.ia.aistream.common.utils.poi.ExcelUtil;
import com.ia.aistream.common.core.page.TableDataInfo;

/**
 * doc_titleController
 *
 * @author aistream
 * @date 2021-01-20
 */
@Controller
@RequestMapping("/doc/title")
public class DocTitleController extends BaseController
{
    private String prefix = "aistream/title";

    @Autowired
    private IDocTitleService docTitleService;

//    @RequiresPermissions("aistream:title:view")
    @GetMapping()
    public String title()
    {
        return prefix + "/title";
    }

    /**
     * 查询doc_title列表
     */
//    @RequiresPermissions("aistream:title:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DocTitle docTitle)
    {
        startPage();
        List<DocTitle> list = docTitleService.selectDocTitleList(docTitle);
        return getDataTable(list);
    }

    /**
     * 导出doc_title列表
     */
//    @RequiresPermissions("aistream:title:export")
    @Log(title = "doc_title", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DocTitle docTitle)
    {
        List<DocTitle> list = docTitleService.selectDocTitleList(docTitle);
        ExcelUtil<DocTitle> util = new ExcelUtil<DocTitle>(DocTitle.class);
        return util.exportExcel(list, "title");
    }

    /**
     * 新增doc_title
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存doc_title
     */
//    @RequiresPermissions("aistream:title:add")
    @Log(title = "doc_title", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DocTitle docTitle)
    {
        return toAjax(docTitleService.insertDocTitle(docTitle));
    }

    /**
     * 修改doc_title
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        DocTitle docTitle = docTitleService.selectDocTitleById(id);
        mmap.put("docTitle", docTitle);
        return prefix + "/edit";
    }

    /**
     * 修改保存doc_title
     */
//    @RequiresPermissions("aistream:title:edit")
    @Log(title = "doc_title", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DocTitle docTitle)
    {
        return toAjax(docTitleService.updateDocTitle(docTitle));
    }

    /**
     * 删除doc_title
     */
//    @RequiresPermissions("aistream:title:remove")
    @Log(title = "doc_title", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(@RequestParam("ids") String ids)
    {
        System.out.println("调用成功remove");
        return toAjax(docTitleService.deleteDocTitleByIds(ids));
    }
}
